package testing;

import gamemngr.GameMngr;
import junit.framework.TestCase;
import logic.GameMap;
import logic.Player;
import logic.moves.SettleMove;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class SettleMoveTest extends TestCase{
	GameMap gm;
	Player p, p2;
	
	@Before
	public void setUp() throws Exception {
		gm = new GameMap();
		p = new Player("Eugene", new GameMngr());
		p2 = new Player("Buka", new GameMngr());
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testSettleMove() {
		SettleMove sm = new SettleMove(gm.getCountries().get("israel"), p);
		assertEquals(false, sm.hasMoved());
		assertEquals(gm.getCountries().get("israel"), sm.getCountry());
		assertEquals(p, sm.getSettler());
		
	}

	@Test
	public void testMakeMove() {
		SettleMove sm = new SettleMove(gm.getCountries().get("Israel"), p);
		assertEquals(gm.getCountries().get("Israel"), sm.getCountry());
		assertEquals(sm.getSettler(), p);
		SettleMove sm2 = new SettleMove(gm.getCountries().get("Palestine"), p);
		assertEquals(gm.getCountries().get("Palestine"), sm2.getCountry());
		assertEquals(sm2.getSettler(), p);
		SettleMove sm3 = new SettleMove(gm.getCountries().get("Palestine"), p2);
		assertEquals(gm.getCountries().get("Palestine"), sm3.getCountry());
		assertEquals(sm3.getSettler(), p);
		sm.makeMove();
		assertEquals(true, sm.hasMoved());
	}

	@Test
	public void testRestore() {
		SettleMove sm = new SettleMove(gm.getCountries().get("Israel"), p);
		assertEquals(gm.getCountries().get("Israel"), sm.getCountry());
		assertEquals(p, sm.getSettler());
		sm.makeMove();
		assertEquals(true, sm.hasMoved());
		sm.restore();
		assertEquals(false, sm.hasMoved());
	}
}
